--------------------------
-- {Frostmourne System} --
------{By Erathorn}-------
--------------------------

-- Description:
-- This script sets up a system that allows only one version of a specific
-- item to be allowed in the world at one time. This is how I would want to
-- see Blizzard implement Frostmourne into the game.
----------------------------------------------------

FROST = {} --Just initializing the FROST table. Don't edit unless you know what you're doing.
FROST.Enable = true --Set to false to disable running of script.
FROST.Id = 80002 --Edit to your desired ItemID
FROST.ItemName = "Frostmourne" --Edit to your desired name to be displayed in the messages
FROST.ConsolePrint = true --Set to false if you do not want a message in your server console everytime someone steals the item.
FROST.WebSupport = true --Set to false if you don't want to update the character DB with the name of the person currently holding the item.
FROST.WebTable = "frostmourne_sys" --Change to whatever your table name is for the websupport feature
FROST.Honorable = false --True: Must be an honorable kill. False: Any kill counts. Default: false
FROST.QuestEnable = false --Do not mess with this for now. It's not working correctly just yet.


--DO NOT edit below without knowledge of Lua scripting--
logcol(2)
print("FrostmourneSystem: Script Initialized...")
function Frost_PlayerKill(event, pPlayer, pVictim)
	if(pVictim:HasItem(FROST.Id) == true) then
		pPlayer:SendAreaTriggerMessage("You've obtained "..FROST.ItemName.." from "..pVictim:GetName().."!")
		pVictim:SendAreaTriggerMessage(FROST.ItemName.." has been taken from you by "..pPlayer:GetName().."!")
		pVictim:RemoveItem(FROST.Id, 1)
		pPlayer:AddItem(FROST.Id, 1)
		if(FROST.WebSupport == true) then
			CharDBQuery("UPDATE `"..FROST.WebTable.."` SET name = '"..pPlayer:GetName().."';")
		end
		if(FROST.ConsolePrint == true) then
			logcol(2)
            print("FrostmourneSystem: "..pPlayer:GetName().." has stolen "..FROST.ItemName.."("..FROST.Id..") from "..pVictim:GetName()..".")
        end
	end
end
if(FROST.Enable == true) then
	if(FROST.Honorable == true) then
		RegisterServerHook(23, "Frost_PlayerKill")
	else
		RegisterServerHook(2, "Frost_PlayerKill")
	end
else
	logcol(2)
	print("FrostmourneSystem: Disabled. (Config Setting)")
end

--Quest Stuff--
--Description:
--This is all the stuff for the Frostmourne quest I am implementing. You don't have to use this feature,
--as I will add a config option at the top to disable this.
-----------------------------------------------------------

